#!/bin/bash

function dist-clean(){
	rm -f *.xpi
	rm -f *.zip
	rm -f *.crx
	echo "Cleaned"
}

function dist-check(){
	ALLJS=`find . -name '*.js'`

	CHECKCONSOLE=`grep console -n $ALLJS`
	if [ "x$CHECKCONSOLE" != "x" ];then
		echo "Console decteted"
		echo $CHECKCONSOLE
		exit;
	fi
}

if [ -e "dist-$1.sh" ]; then
	"./dist-$1.sh"
elif [ "$1" == "clean" ]; then
	dist-clean
else
	dist-check
	for i in `ls dist-*.sh` ;do
		"./$i" ;
	done

	echo "All Done"
fi

for i in `ls *.zip *.xpi *.crx 2>/dev/null `;do
	md5sum $i
done
